﻿using FluentMigrator;

namespace ProgressTracker.Data.Migrations
{
    [Migration(201404131144)]
    public class _1144_Add_UserId_Fields_To_Day_And_Task : Migration
    {
        public override void Up()
        {
            Alter.Table("Days").AddColumn("UserId").AsInt32().ForeignKey().WithDefaultValue(-1);
            Alter.Table("Tasks").AddColumn("UserId").AsInt32().ForeignKey().WithDefaultValue(-1);

            //Don't actually want the default value to last on the column, just need to add the columns in with a value and
            //do not want them to be nullable. Will have to assign proper users to days/tasks later.
            Delete.DefaultConstraint().OnTable("Days").OnColumn("UserId");
            Delete.DefaultConstraint().OnTable("Tasks").OnColumn("UserId");
        }

        public override void Down()
        {
            Delete.Column("UserId").FromTable("Days");
            Delete.Column("UserId").FromTable("Tasks");
        }
    }
}
